<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>攻略分类管理</title>
	<#include "../common/header.ftl" >

    <script src="/static/jquery/jquery-form/jquery.form.js"></script>
    <script src="/static/jquery/jquery-bootstrap/jquery.bootstrap.min.js"></script>
    <script src="/static/My97DatePicker/WdatePicker.js"></script>

    <style>
        .modal-body img {
            width: 100%;
        }
    </style>


    <script>
        $(function () {
            //添加触发模态框
            $('#addStrategyBtn').click(function () {
                //清空回显
                $('#strategyCatalogModal input').val('');
                $('#strategyCatalogModal').modal('show');
            });

            //修改功能
            $('.btn-recomment').click(function () {
                var json = $(this).data('json');
                $('#strategyCatalogModal #id').val(json.id);
                $('#strategyCatalogModal [name="name"]').val(json.name);
                $('#strategyCatalogModal #strategySelect').val(json.strategyId);
                $('#strategyCatalogModal [name="sequence"]').val(json.sequence);
                $('#strategyCatalogModal [name="state"]').val(json.state);
                $('#strategyCatalogModal').modal('show');
            });

            //提交添加/修改表单
            $('#saveCommendBtn').click(function () {
                $('#commendForm').ajaxSubmit(function (data) {
                    if (data.success) {
                        $.messager.alert('温馨提示', '操作成功!  2s后刷新页面');
                        setTimeout(function () {
                            window.location.reload();
                        }, 2000);
                    } else {
                        $.messager.alert('温馨提示', data.msg);
                    }
                });
            })

        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
	<#include "../common/top.ftl" >
    <div class="row">
        <div class="col-sm-3">
            <!--设置用于菜单回显-->
                <#assign currentMenu="strategyCatalog">
			<#include "../common/menu.ftl" >
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">大攻略管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/strategyCatalog/list.do" method="post">
                <div class="form-group">
                    <input id="currentPage" type="hidden" name="currentPage" value="${(qo.currentPage)!}">
                    <label for="keyword">攻略搜索:</label>
                    <select id="strategySelect" name="strategyId" class="form-control form-control-chosen">
                        <option value="-1">请选择所属攻略</option>
                        <#list strategies as strategy>
                            <option value="${strategy.id}">${strategy.title}</option>
                        </#list>
                    </select>
                    <script>
                        $('#strategySelect').val(${(qo.strategyId)!})
                    </script>
                </div>


                <input type="submit" id="btn_query" class="btn btn-success" value="查询">

            </form>

            <button class="btn btn-success" id="addStrategyBtn">添加攻略分类</button>

            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>分类名称</th>
                    <th>所属攻略</th>
                    <th>排序</th>
                    <th>状态</th>
                </tr>
                </thead>
				<#list  pageInfo.list as strategyCatalog>
					<tr>
                        <td>${(strategyCatalog.name)!}</td>
                        <td>${(strategyCatalog.strategy.title)!}</td>
                        <td>${(strategyCatalog.sequence)!}</td>
                        <td>${(strategyCatalog.stateName)!}</td>
                        <td>
                            <button class="btn btn-info btn-xs btn-recomment"
                                    data-json='${(strategyCatalog.jsonString)!}'>
                                修改
                            </button>

                        </td>
                    </tr>
                </#list>
            </table>

			<#include "../common/page.ftl" >
        </div>
    </div>
</div>


<#--推荐模态框-->
<div id="strategyCatalogModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="commendForm" class="form-horizontal" method="post" action="/strategyCatalog/saveOrUpdate.do"
                      style="margin: -3px 118px">
                    <input id="id" type="hidden" name="id" value=""/>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">分类名称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="name" placeholder="分类名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">所属攻略</label>
                        <div class="col-sm-9">
                            <select id="strategySelect" name="strategy.id" class="form-control form-control-chosen">
                                <option value="-1">请选择所属攻略</option>
                                <#list strategies as strategy>
                                    <option value="${strategy.id}">${strategy.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">排序</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="sequence" placeholder="排序">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">状态</label>
                        <div class="col-sm-9">
                            <select class="form-control" autocomplete="off" name="state">
                                <option value="1">启用</option>
                                <option value="-1">禁用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveCommendBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>


</body>
</html>